package com.sdjenkins.lab;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class FizzBuzz {

	public static void main(String... p) {
		
		 FizzBuzz.primeFactors(42);
	}
	

	public static  Set<Integer> primeFactors(int number) {

	        // find primes to sqrt(number)
	        
	        List<Integer> primes = new ArrayList<Integer>();
	        int max = (int) Math.sqrt(number)+1; // this is the biggest prime we need to find
	        if (2 < max) primes.add((int)2);
	        if (3 < max) primes.add(3);
	        
	        if (5 < max) {  // get primes of 5 and above
	                for (int i=5; i <= max; i=i+2) {
	                        boolean prime = true;
	                        for (int j = 3; j < i; j++) {
	                                if (i == i/j * j) break; // reject as not a prime
	                                
	                        }
	                        primes.add(i);
	        
	                } 
	        }

	        // Now see which of the gathered primes divide exactly into (number)
	        
	        Set<Integer> pf = new HashSet<Integer>();
	        for (Integer nn : primes) {
	                int n = nn;
	                if (number == number/n * n) pf.add(nn);
	        }
	        
	        return pf;      
	        
	          
	}         
	          









	}
